#include "SDLRenderer.h"

SDLRenderer* SDLRenderer::instance = nullptr;

SDLRenderer::SDLRenderer()
	: width(800)
	, height(600)
{
}

SDLRenderer::~SDLRenderer()
{
	SDL_DestroyRenderer(ren);
	SDL_DestroyWindow(win);
}

void SDLRenderer::Init()
{
	win = SDL_CreateWindow("Final Bartasy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN);
	if(win == nullptr)
	{
		std::cout << SDL_GetError() << std::endl;
	}

	ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);
	if(ren == nullptr)
	{
		std::cout << SDL_GetError() << std::endl;
	}
}

void SDLRenderer::SetResolution(int width, int height)
{
	this->width = width;
	this->height = height;

	Init();
}

void SDLRenderer::Clear()
{
	SDL_RenderClear(ren);
}
void SDLRenderer::Present()
{
	SDL_RenderPresent(ren);
}
